const botMgr = require("./app/botmgr").default;
console.info(botMgr);

var name = "";
var link = ""
for (var i = 0; i < process.argv.length; i = i + 2) {
    if (process.argv[i] == '-n') {
        var v = process.argv[i + 1]
        name = v
    }
    if (process.argv[i] == '-l') {
        var v = process.argv[i + 1]
        link = v
    }
}
if (name == "") {
    console.log('name is required : -n name')
    process.exit()
}
if (link == "") {
    console.log('link is required : -l 127.0.0.1:8080')
    process.exit()
}
console.log(link);
new botMgr(name, "http://" + link);
var crontab = require("node-crontab");

var mins = Math.floor(1 + Math.random() * 59)
crontab.scheduleJob("50 " + mins + " 04 * * *", function () {
    process.exit();
});